//
//  SupervisionSumitCell.m
//  HengHuaSupervision
//
//  Created by XD-XY on 3/22/14.
//  Copyright (c) 2014 XD-XY. All rights reserved.
//

#import "SupervisionSumitCell.h"
#import "XDHeader.h"
#import "XDTools.h"
@implementation SupervisionSumitCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        [self makeView];
    }
    return self;
}

-(void)makeView
{
    CGFloat aheight = 122/2.0f;
    UIColor * color = mHomepagelist_Text_Color;
    //设备编号
    self.assertidLabel = [UILabel initLabel:CGRectMake(0,0, 346/2.0f, aheight) textFont:mHomepage_text_Font textColor:color textAlignment:NSTextAlignmentCenter];
    
    //设备名称
    self.assertnameLabel = [UILabel initLabel:CGRectMake(width_x(_assertidLabel)+1, 0, 188/2.0f, aheight) textFont:mHomepage_text_Font textColor:color textAlignment:NSTextAlignmentCenter];
    
    //标签编号
    self.tagidLabel = [UILabel initLabel:CGRectMake(width_x(_assertnameLabel)+1, 0, 346/2.0f, aheight) textFont:mHomepage_text_Font textColor:color textAlignment:NSTextAlignmentCenter];
    
    //贴签部位
    self.partLabel = [UILabel initLabel:CGRectMake(width_x(_tagidLabel)+1, 0, 202/2.0f, aheight) textFont:mHomepage_text_Font textColor:color textAlignment:NSTextAlignmentCenter];
    
    //扫描地点
    self.locationLabel = [UILabel initLabel:CGRectMake(width_x(_partLabel)+1, 0, 518/2.0f, aheight) textFont:mHomepage_text_Font textColor:color textAlignment:NSTextAlignmentCenter];
    
    //贴签时间
    self.creatTimeLabel = [UILabel initLabel:CGRectMake(width_x(_locationLabel)+1, 0, 388/2.0f, aheight) textFont:mHomepage_text_Font textColor:color textAlignment:NSTextAlignmentCenter];
    
    [self addSubview:_assertidLabel];
    [self addSubview:_assertnameLabel];
    [self addSubview:_tagidLabel];
    [self addSubview:_partLabel];
    [self addSubview:_locationLabel];
    [self addSubview:_creatTimeLabel];
    
    //cell未选中效果
    self.diselectBg = [[UIImageView alloc] init];
    _diselectBg.frame = CGRectMake(0, 0, self.frame.size.width,self.frame.size.height);
    self.backgroundView = _diselectBg;
    
    //cell选中效果
    self.selectBg = [[UIImageView alloc] init];
    _selectBg.frame = CGRectMake(0, 0, self.frame.size.width,self.frame.size.height);
    _selectBg.image = [XDTools stretchableImag:mHomepage_Cell_select_Img];
    self.selectedBackgroundView = _selectBg;
}

-(void)isHarderTableViewCell
{
    //表头改变字体大小和颜色
    [self changeLabelTextcolorAndFont:_assertidLabel];
    [self changeLabelTextcolorAndFont:_assertnameLabel];
    [self changeLabelTextcolorAndFont:_tagidLabel];
    [self changeLabelTextcolorAndFont:_partLabel];
    [self changeLabelTextcolorAndFont:_locationLabel];
    [self changeLabelTextcolorAndFont:_creatTimeLabel];
    
    //创建分割线
    UIImage * image = mHomepage_Head_Cutline_Img;
    UIImageView * lineView1  = [[UIImageView alloc] initWithFrame:CGRectMake(width_x(_assertidLabel), 0, image.size.width, image.size.height)];
    lineView1.image = image;
    UIImageView * lineView2  = [[UIImageView alloc] initWithFrame:CGRectMake(width_x(_assertnameLabel), 0, image.size.width, image.size.height)];
    lineView2.image = image;
    UIImageView * lineView3  = [[UIImageView alloc] initWithFrame:CGRectMake(width_x(_tagidLabel), 0, image.size.width, image.size.height)];
    lineView3.image = image;
    UIImageView * lineView4  = [[UIImageView alloc] initWithFrame:CGRectMake(width_x(_partLabel), 0, image.size.width, image.size.height)];
    lineView4.image = image;
    UIImageView * lineView5  = [[UIImageView alloc] initWithFrame:CGRectMake(width_x(_locationLabel), 0, image.size.width, image.size.height)];
    lineView5.image = image;
    
    [self addSubview:lineView1];
    [self addSubview:lineView2];
    [self addSubview:lineView3];
    [self addSubview:lineView4];
    [self addSubview:lineView5];

}

-(void)changeLabelTextcolorAndFont:(UILabel *)label
{
    label.textColor = mHomepage_Head_Text_Color;
    label.font = mHomepage_Head_text_Font;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
